<?php 
class Hd{
	public static function run(){

		if(!is_dir('Application')){
//			创建目录			
			self::_createDir();
//			复制文件	
			self::_copyFile();
		}
//		载入核心文件
		self::_loadCore();
		App::run();
	}
	/**
	 * 复制文件
	 */
	private static function _copyFile(){
		copy('Hdphp/Common/error.php','Public/error.php');
		copy('Hdphp/Common/success.php','Public/success.php');
		copy('Hdphp/Common/config.php','Application/Common/Conf/config.php');
		copy('Hdphp/Common/config.php','Application/Home/Conf/config.php');
		copy('Hdphp/Common/index.php','Application/Home/View/Index/index.php');
		copy('Hdphp/Common/IndexController.class.php', 'Application/Home/Controller/IndexController.class.php');
		
	}
	
	private static function _loadCore(){
		$coreFile=array(
			'Hdphp/Library/App.class.php',
			'Hdphp/Library/Controller.class.php',
			'Hdphp/Library/Functions.php',
		);
		foreach ($coreFile as $f) {
//			永远载入一次使用require_once避免多次载入程序报错
			require_once $f;
		}
	}
	
	/**
	 * 创建目录
	 */
	private static function _createDir(){
		$dirArr=array(
			'Application/Common/Conf',
			'Application/Home/Conf',
			'Application/Home/Controller',
			'Application/Home/View/Index',
			'Public',
		);
		foreach($dirArr as $d){
//			如果不是一个目录的递归创建
			is_dir($d) || mkdir($d,0777,true);
		}
		
	}
	
}

Hd::run();





 ?>